//
//  FirstTableViewCell.m
//  HDYS
//
//  Created by qianfeng on 15-4-22.
//  Copyright (c) 2015年 kay. All rights reserved.
//

#import "FirstTableViewCell.h"

#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define SHAREBTN_WIDTH 20

@interface FirstTableViewCell ()
{
    UILabel *_nameLabel;
    UILabel *_priceLabel;
    UILabel *_saleOutLabel;
}
@end

@implementation FirstTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createSubviews];
    }
    return self;
}

-(void)createSubviews{
    _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH - 30 - SHAREBTN_WIDTH, SHAREBTN_WIDTH)];
//    nameLabel.text = @"春夏雪纺衬衫";
    _nameLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:_nameLabel];
    
    //分割线
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(_nameLabel.frame.origin.x + _nameLabel.frame.size.width, _nameLabel.frame.origin.y, 0.5, _nameLabel.frame.size.height)];
    lineView.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:lineView];
    
    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    shareBtn.frame = CGRectMake(lineView.frame.origin.x + 9, lineView.frame.origin.y, SHAREBTN_WIDTH, SHAREBTN_WIDTH);
    [shareBtn setImage:[UIImage imageNamed:@"bl_iconfont-fenxiang"] forState:UIControlStateNormal];
    [shareBtn addTarget:self action:@selector(shareBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:shareBtn];
    
    _priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(_nameLabel.frame.origin.x , _nameLabel.frame.origin.y + _nameLabel.frame.size.height + 10, 60, SHAREBTN_WIDTH)];
    _priceLabel.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:_priceLabel];
    
    UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(_priceLabel.frame.origin.x + _priceLabel.frame.size.width, _priceLabel.frame.origin.y, 0.5, _priceLabel.frame.size.height)];
    lineView2.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:lineView2];
    
    UILabel *saleOutLabel = [[UILabel alloc] initWithFrame:CGRectMake(_priceLabel.frame.origin.x + _priceLabel.frame.size.width + 5, _priceLabel.frame.origin.y, 100, _priceLabel.frame.size.height)];
    saleOutLabel.font = [UIFont systemFontOfSize:13];
    saleOutLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:saleOutLabel];
}

- (void)configUIWithModel:(MainDataModel *)model {
    _nameLabel.text = model.gname;
    _priceLabel.text = model.price;
    _saleOutLabel.text = model.gtotal;
}

-(void)shareBtnClick{
    
}

@end
